home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AOL File Library: 2,801 to 2,900
/
aol-file-protocol-4400-2801-to-2900.zip
/
AOLDLs
/
C++ Files Library
/
CModalDialog C++ Class
/
CModalDialogClass.v100.sit
/
CModalDialog Class
/
CModalDialog.h
< prev
next >
Wrap
Text File
|
1995-10-11
|
5KB
|
132 lines
// CModalDialog.h
// Copyright ⌐ 1995 by Michael F. Kamprath, All rights reserved.
//
// Contact information:
// mailto:kamprat@leonardo.net
// http://www.leonardo.net/kamprath
//
// License:
// This code may be freely used in free and shareware products. Commercial product
// users must supply me with a free, fully licensed copy of the product this code is
// used in. In either case, users should notify me of their use of this code.
//
// This code may be freely distributed in it's non-modified form. It's original archive
// should be kept intact.
//
// Version History:
// v1.0.0 - Inititial release.
//
#pragma once
#ifndef __DIALOGS__
#include <Dialogs.h>
#endif
class CModalDialog
{
protected:
// theDialog is made protected so that inheiritted classes can
// have access to it. Not intended for public use.
DialogPtr theDialog;
private:
// This is private stuff. No peeking!
friend pascal Boolean CModalDialogFilter( DialogPtr theDlg, EventRecord *theEvent, short *itemHit);
ModalFilterUPP dialogFilterUPP;
short dlogResID;
short defaultItem;
short cancelItem;
Boolean showHasBeenCalled;
// *private functions*
// DO NOT depend on these!
void GetDefaultRect( Rect& theRect );
void FrameDefaultButton();
void InvalidateDefaultRect(void);
void FakeDefaultButtonPress( );
void FakeCancelButtonPress( );
public:
// The Constructor and Destructor. You must pass the DLOG resource id
// for the dialog in the constructor. You may optionally specify non-default
// values for the default and cancel button item IDs.
CModalDialog( short dlogResID, // DLOG resource id
short defaultID = 1, // Default button
short cancelID = 2); // cancel button
virtual ~CModalDialog();
// Set's the Dialog port as the current GrafPort.
void SetDialogPort( void );
// You may use these functions rather then their MacOS equivalents.
void GetItemInfo( short item, short* itemType, Handle* itemHandle, Rect* itemRect );
void SetItemInfo( short item, short itemType, Handle itemHandle, Rect* itemRect );
// Change the Default and Cancel item. CModalDialog tracks the id's of the
// default and cancel buttons to properly respond to their key equivalents
// and to prioperly draw a box around the default item. Changing the default item
// automatically creates an update event to ensure the dialog is properly redrawn.
void SetDefaultItem( short newVal );
void SetCancelItem( short newVal );
// Show and hide the dialog. Note: Hiding a dialog is not the same as disposing it.
// Delete your CModalDialog object to release all memory ascociated with it.
void Show( void );
void Hide( void );
// Use DoOneModalLoop as you would the ::ModalDialog() routine in C code. It returns
// a short indicating the item number which was hit in the dialog.
short DoOneModalLoop( void );
//
// Functions that you may overide.
//
// If you want to customize the dialog's updates, override DrawDialog(). If you want
// to have access to update events to update other application windows, override
// UpdateFilter(). NOTE: DrawDialog() should only have drawing code. BeginUpdate() and
// EndUpdate() is called by UpdateFilter(). The CModalDialog version of DrawDialog just
// draws the DITL and frames the default button. If you override DrawDialog(), you should
// head or tail patch it.
virtual void DrawDialog( void );
// These are the filter functions called by the ModalDialog filter for each dialog.
// The filter functions should be "conditionally head patched." That is, override the
// function, but if your overide does nothing with the event that called it, call the
// CModalDialog version of the filter and return it's results. For example, if you want
// you dialog to respond to the user pressing the space bar, overide KeyDownFilter. In
// version, inspect the keydown event. If it is a space key, do your stuff and return true.
// If it isn't a space key, pass the event along to CModalDialog::KeyDownFilter() and return
// what CModalDialog::KeyDownFilter() returns.
// Overide UpdateFilter() to have access to update events. The CModalDialog version
// calls DrawDialog() if the update event is for the this object's dialog.
virtual Boolean UpdateFilter( DialogPtr theDlg, EventRecord *theEvent, short *itemHit);
// Override KeyDownFilter() to have access to key down and autokey events. the CModalDialog
// looks for equivalent key presses for the default and cancel buttons.
virtual Boolean KeyDownFilter( DialogPtr theDlg, EventRecord *theEvent, short *itemHit);
// Override MouseDownFilter() to have access to mousedown events. The CModalDialog version
// does nothing with mouse down events. You should still head patch it though for future
// code compatibility (that is, in case I add menu handling routines for the Edit menu).
virtual Boolean MouseDownFilter( DialogPtr theDlg, EventRecord *theEvent, short *itemHit);
// Override OtherFilter() to have access to all other events. The CModalDialog version
// does nothing with any other event. You should still head patch it though for future
// code compatibility.
virtual Boolean OtherFilter( DialogPtr theDlg, EventRecord *theEvent, short *itemHit);
};